﻿using Exceptionless;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
using Exceptionless.NLog;

namespace TestLogConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // TestWriteConsoleLog();

            TestExceptionlessTest();
        }

        //测试Exceptionless 日志收集分析功能 
        private static void TestExceptionlessTest()
        {
            ExceptionlessClient.Default.Startup("FElSXhwef5FPKQgI4v0319QFHkfWiFeR5HwGWAyi");
            //需要一个logprovider 中间者进行桥接  Nlog有现成插件  和serialLog
            ServiceCollection services = new ServiceCollection();

            //注入日志对象
            services.AddLogging(logBuilder =>
            {
                logBuilder.AddNLog();
               
            });

            using (var sp = services.BuildServiceProvider())
            {

            }

        }

        private static void TestWriteConsoleLog()
        {
            ServiceCollection services = new ServiceCollection();
            services.AddLogging(logBuilder =>
            {
                logBuilder.AddConsole(); //天剑控制台 日志记录者
                logBuilder.AddEventLog();// 添加多个日志Provice  这个是win特有的 事件查看器中。很nice

                logBuilder.AddNLog();
                logBuilder.SetMinimumLevel(LogLevel.Trace); // 设置日志的最小输出级别。
            });
            services.AddScoped<TestConsoleLog>();
            using (var sp = services.BuildServiceProvider())
            {
                TestConsoleLog testLog = sp.GetRequiredService<TestConsoleLog>();
                testLog.WriteLog();
            }
        }
    }
}
